An Overview of the features you can use to expand a query, thereby avoiding no or insufficient results.
removeWordsIfNoResults
parameter helps you make an initial query less and less specific until results are found. The right value to choose for a given use case may depend on the language searched as well as usage patterns.
You can choose one of these four behaviors: none
(default), lastWords
, firstWords
, allOptional
.
none
lastWords
firstWords
allOptional
AND
operator between words to OR:
allOptional
as before would return a far wider range of results— blue towels, books on iPhone development, and camera cases. Breadth would come at the expense of relevance, so it’s best to use this parameter cautiously.
optionalWords
, which is sent at query time. See Creating a list of optional words for more information.removeWordsIfNoResults
from the default setting of none
.
Some non-alphanumeric characters, or “separators”, trigger special behavior in the engine. Specifically, they trigger the concatenation of the surrounding alphanumeric characters. For example, the query t-shirt
, matches on tshirt
as well as t shirt
. Additionally, the search looks for the parts in order. Looking for particular parts in a specific order is called a sequence expression. This means the query t-shirt
matches t-shirt
, t shirt
, or tshirt
, but not shirt t
.
Therefore, if you’ve enabled removeWordsIfNoResults
, and a user searches for a term like XYZ-b5
, you may expect the query to match records containing only XYZ
, if there are no results for XYZ-b5
. This isn’t the case; because of concatenation and the subsequent sequence expression, the query matches XYZ b5
or XYZb5
, not only XYZ
.
Please refer to the guide on searching in hyphenated attributes SKUs, ISBNs, phone, and serial numbers for best practices when performing this kind of search. The documentation also has in-depth guides on tokenization, splitting, and concatenation, if you’re interested in learning more on these topics.